 
<?php 
	include_once("header.php");
?>

<script type="text/javascript"  src="/include/ajaxfileupload.js"></script>

<link rel="stylesheet" href="/include/coachdash.css">

<div id="regbox">
     <div id="regform" >
		      <!-- step 1 -->
		       <div id="step1" style=" position:relative; ">

 


                <div class="formgroup" style="height:150px">
                     <h3><span class="mustspan">*</span>项目</h3>
                     <div class="inputcontent" id="stypeselectdiv">
                      <span svar="1" selectstatus="unselected" class="stypeselector buttondiv">健身</span> 
                          <span svar="2" selectstatus="unselected" class="stypeselector buttondiv">羽毛球</span> 
                          <span svar="3" selectstatus="unselected" class="stypeselector buttondiv">网球</span> 
                      <br>

                      <span svar="4" selectstatus="unselected" class="stypeselector buttondiv">高尔夫</span> 
                      <span svar="5" selectstatus="unselected" class="stypeselector buttondiv">游泳</span> 
                      <span svar="6" selectstatus="unselected" class="stypeselector buttondiv">瑜伽</span> 
                        <br>

                      <span svar="7" selectstatus="unselected" class="stypeselector buttondiv">跑步</span> 
                      <span svar="0" id="showorthertypebut"  selectstatus="unselected" class="stypeselector buttondiv">其他</span> 
                      <br>

 
                       </div>
                </div>
 
 
                 <div class="formgroup" id="othertypediv" style="display:none">
                     <h3> 其他项目</h3>
                     <input type="input" value="<?=$c_course->othertype?>" name="othertype" id="othertype" placeholder="如果以上没有列有">
                </div>

 
                <div class="formgroup" style="height:101px;">
                    <h3>课程要点</h3>
                   <textarea name="course_desc" id="course_desc" placeholder="课程要点"><?=$c_course->course_desc?></textarea>
                    <div class="clearbox"></div>
                </div>


                 <div class="formgroup">
                     <h3> <span class="mustspan">*</span>价格</h3>
                     <input type="input" value="<?=$c_course->price?>" name="price" id="price" placeholder="设置每小时价格">
                </div>


  		 	          <div class="blankbox"></div>

		        </div>
 
	</div>		    

	      <div style="width:90%;  text-align:center; margin:auto; margin-top:20px;">
				  <button id="submitButton" type="" class="btn btn-primary">
				     <div id="submitButtonText">设置</div>
				  </button>
	      </div>

	 	  <div style="height:20px;">
	       </div>

</div>
 
<script type="text/javascript">

   var userid = '';
   var phonenumber = '';
   var wx_openid = '<?=$wx_openid?>';
   var stypevar = '<?=$c_course->stype?>';
    var othertypeval = '<?=$c_course->othertype?>';

   $("#showorthertypebut").on('click',function(){
        $("#othertypediv").show();
   });

   $(".stypeselector").on('click',function(){
        var selectedvar = $(this).attr("svar");
        $(".stypeselector").removeClass("buttondiv_selected");
        $(".stypeselector").addClass("buttondiv");
        $(this).addClass("buttondiv_selected");
        $(this).removeClass("buttondiv");
        stypevar = selectedvar;
        if(stypevar!=0){
             $("#othertypediv").hide();
             $("#othertype").val("");
        }
   });

   $(".stypeselector").each(function(){
        var selectedvar = $(this).attr("svar");
        if( selectedvar == stypevar){
             $(this).addClass("buttondiv_selected");
        }
    });

   if(othertypeval!=''){
        $("#othertypediv").show();
   }



   
   $("#submitButton").on('click',function(){
  	     sendInfo_1();
   });

    function showlayer(showword){
			layer.open({
			    content:showword,
			    style: 'background-color:#09C1FF; color:#fff; border:none;',
			    time: 2
			});
    }

    function sendInfo_1(){

 	    //获取所选取的
   
      var stype = stypevar;
      var course_desc = $("#course_desc").val();
      var othertype = $("#othertype").val();
      var price = $("#price").val();
 
 	    layer.open({
  		    content: '正在注册',
  		    className: 'bluelayer'
  		});

        $.ajax({
            url: '/index.php/coach/admin_couseinfo_handle',
            type: 'POST',
            data:{wx_openid:wx_openid,othertype:othertype,stype:stype,course_desc:course_desc,price:price  },
            dataType: 'json',
            error: function(){
                  alert('Error loading PHP document'); 
                  posting = false;
                 },
            success: function(result){
 
       				  if(result.result==7){
                      layer.open({
      						    content: '请重新登录',
      						    className: 'bluelayer',
      						    time: 2
      					  });
                      return;
                 }

                if(result.result==9){
                      layer.open({
                      content: '请先完善基本资料',
                      className: 'bluelayer',
                      time: 2
                  });
                      return;
                 }


                if(result.result==1){
                      layer.open({
						    content: '修改完成',
						    className: 'bluelayer',
						    time: 2
						});
                      return;
		 	         //send sms

                }else{
                      layer.open({
						    content: '请填写完整',
						    className: 'bluelayer',
						    time: 2
						});
                      return;

                }
                posting = false;
            }
        });

    }

 
    // function sendInfo_3(){
    	
    //    var userthumb = $("#userthumb").attr("src");
    //    var selfintro = $("#selfintro").val();
    //    var sporttitle = $("#sporttitle").val();
    //    var resume = $("#resume").val();

    //     $.ajax({
    //         url: '/api_createinfo_3.php',
    //         type: 'POST',
    //         data:{ userid:userid,userthumb:userthumb,selfintro:selfintro,sporttitle:sporttitle,resume:resume},
    //         dataType: 'json',
    //         error: function(){
    //               alert('Error loading PHP document'); 
    //               posting = false;
    //              },
    //         success: function(result){


    //             if(result.result==1){
    //                   showlayer("已完成注册");
			 //         $("#step3").hide();
			 //         $("#step4").fadeIn(500);

    //                   $("#submitButton").hide();
    //                   currentstep ++;
		 	//          //send sms
    //                  $('html, body').animate({scrollTop:220}, 'slow'); 

    //             }else{
    //                  alert("请填写完整");
    //             }
    //             posting = false;
    //         }
    //     });
    // }

</script>



 

<?php 
	include_once("footer.php");
?>


